<%@ taglib prefix="s" uri="/struts-tags" %>
<%@page import="th.co.mfec.mca.common.ProjectConstant"%>

<div id="content">
   <s:form id="mainForm" action="userProfileManagement-search.htm" method="post" >
   <s:hidden id="selectedId" name="selectedId" />
   <s:hidden name="userProfileBean.uspId" />
   <s:hidden name="userProfileBean.uspUserName" />
   <s:hidden id="sortMode" name="sortMode" />
   <s:hidden id="logRequestPage" name="logRequestPage" value="%{logPagingBean.currentPage}" />
      <div class="topic">Log User Profile</div>
      <div id="searchForm" class="dataField">
      <div id="dialoginfo"></div>
          <div class="tableContent">
            <table>
              <tr>
                <td colspan="4"><div align="center"><s:text name="label.username" /> : <s:property value="userProfileBean.uspUserName" /></div></td>
              </tr>
              <tr>
                <th>&nbsp;</th>
                <td>&nbsp;</td>
                <th>&nbsp;</th>
                <td>&nbsp;</td>
              </tr>
            </table>
          </div>
      </div>
        <!-- / search result -->
        <!-- search result -->
        
          <div id="searchResult">
          <div class="hr"></div>
          <div class="tableSearchResult">
            <div class="pagefound">
              <table>
                <tr>
                  <td class="L">
                  	<strong>Page</strong> <s:property value="%{logPagingBean.currentPage}"/>/ <s:property value="%{logPagingBean.pageCount}"/>
                    </td>
                  <td class="R">
                    <div class="pagenum">
                   	<a href="javascript:changePage(1)"><span>&laquo;</span></a>&nbsp;&nbsp;
                   	<a href="javascript:changePage(<s:property value="%{logPagingBean.perviousPage}"/>)"><span>&#8249;</span></a>&nbsp;&nbsp;
                   	<s:iterator status="rowstatus" value="%{logPagingBean.displayPage}" >
                   		<a href="javascript:changePage(<s:property />)"><s:property /></a>&nbsp;&nbsp;
                   	</s:iterator>
                   	<a href="javascript:changePage(<s:property value="%{logPagingBean.nextPage}"/>)"><span>&#8250;</span></a>&nbsp;&nbsp;
                   	<a href="javascript:changePage(<s:property value="%{logPagingBean.pageCount}"/>)"><span>&raquo;</span></a>&nbsp;&nbsp;
                   	</div>
                  </td>
                </tr>
              </table>
            </div>
            <table>
              <tr>
                <th><a href="javascript:changeSortMode()">Timestamp</a></th>
                <th>User Group</th>
                <th>Action</th>
                <th>IP Address</th>
              </tr>
              
              <s:iterator value="logResultList" status="rowstatus" id="logResultList" >
              	<tr>
                	<td><s:date name="uacDatetime" format="dd/MM/yyyy HH:mm:ss" /></td>
                	<td><s:property value="usgName"/></td>
                	<td><!-- Place action here -->&nbsp;</td>
                	<td><s:property value="uacIpAddr"/></td>
              	</tr>
              </s:iterator>
            </table>
            
            <div class="pagefound">
			  <table>
                <tr>
                  <td class="L">
                  	<strong>Found</strong> <s:property value="%{logPagingBean.totalRows}"/> row(s)
                  	&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
                  	<strong>Display</strong>&nbsp;
                    <s:textfield id="logRowsPerPage" name="logRowsPerPage" value="%{logPagingBean.rowsPerPage}" cssStyle="width: 60px; text-align: right;" onchange="changeRowPerPage();"/>
                    &nbsp;
                    row(s) per page
                  	</td>
                  <td class="R">
                    <div class="pagenum">
                   	<a href="javascript:changePage(1)"><span>&laquo;</span></a>&nbsp;&nbsp;
                   	<a href="javascript:changePage(<s:property value="%{logPagingBean.perviousPage}"/>)"><span>&#8249;</span></a>&nbsp;&nbsp;
                   	<s:iterator status="rowstatus" value="%{logPagingBean.displayPage}" >
                   		<a href="javascript:changePage(<s:property />)"><s:property /></a>&nbsp;&nbsp;
                   	</s:iterator>
                   	<a href="javascript:changePage(<s:property value="%{logPagingBean.nextPage}"/>)"><span>&#8250;</span></a>&nbsp;&nbsp;
                   	<a href="javascript:changePage(<s:property value="%{logPagingBean.pageCount}"/>)"><span>&raquo;</span></a>&nbsp;&nbsp;
                   	</div>
                  </td>
                </tr>
              </table>
              </div>
            
            <br />
          </div>
          </div>
          
          <div class="button">
   			<table align="center">
            <tr>
              <td><span id="button"><a href="javascript:onClickBack();"><span><s:text name="button.back" /></span></a></span></td>
            </tr>
        	</table>
   		  </div>
          
        </s:form>
    </div>

<script>
function changePage(page) {
	$j("#logRequestPage").val(page);
	$j("#mainForm")
		.attr("action","userProfileManagement-viewAccessLog.htm")
		.submit(); 
}

function changeRowPerPage(){
	$j("#mainForm")
	.attr("action","userProfileManagement-viewAccessLog.htm")
	.submit(); 
	
}

function changeSortMode(){
	var sortMode = $j("#sortMode").val();

	if(sortMode == "ASC"){
		 $j("#sortMode").val("DESC");
	}else if(sortMode == "DESC"){
		$j("#sortMode").val("ASC");
	}

	$j("#mainForm")
	.attr("action","userProfileManagement-viewAccessLog.htm")
	.submit();
	
}

function onClickBack(){
    $j("#mainForm").attr("action","userProfileManagement-view.htm"); 
  	$j("#mainForm").submit();
}

</script>